home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1994 November / macformat-018.iso / Utility Spectacular / Developer / flex-2.4.6 / flex.1 < prev    next >
Encoding:
Text File  |  1994-07-23  |  25.1 KB  |  1,002 lines  |  [TEXT/KAHL]

  1. .TH FLEX 1 "November 1993" "Version 2.4"
  2. .SH NAME
  3. flex \- fast lexical analyzer generator
  4. .SH SYNOPSIS
  5. .B flex
  6. .B [\-bcdfhilnpstvwBFILTV78+ \-C[aefFmr] \-Pprefix \-Sskeleton]
  7. .I [filename ...]
  8. .SH DESCRIPTION
  9. .I flex
  10. is a tool for generating
  11. .I scanners:
  12. programs which recognized lexical patterns in text.
  13. .I flex
  14. reads
  15. the given input files, or its standard input if no file names are given,
  16. for a description of a scanner to generate.  The description is in
  17. the form of pairs
  18. of regular expressions and C code, called
  19. .I rules.  flex
  20. generates as output a C source file,
  21. .B lex.yy.c,
  22. which defines a routine
  23. .B yylex().
  24. This file is compiled and linked with the
  25. .B \-lfl
  26. library to produce an executable.  When the executable is run,
  27. it analyzes its input for occurrences
  28. of the regular expressions.  Whenever it finds one, it executes
  29. the corresponding C code.
  30. .PP
  31. For full documentation, see
  32. .B flexdoc(1).
  33. This manual entry is intended for use as a quick reference.
  34. .SH OPTIONS
  35. .I flex
  36. has the following options:
  37. .TP
  38. .B \-b
  39. generate backing-up information to
  40. .I lex.backup.
  41. This is a list of scanner states which require backing up and the input
  42. characters on which they do so.  By adding rules one can remove
  43. backing-up states.  If all backing-up states are eliminated and
  44. .B \-Cf
  45. or
  46. .B \-CF
  47. is used, the generated scanner will run faster.
  48. .TP
  49. .B \-c
  50. is a do-nothing, deprecated option included for POSIX compliance.
  51. .IP
  52. .B NOTE:
  53. in previous releases of
  54. .I flex
  55. .B \-c
  56. specified table-compression options.  This functionality is
  57. now given by the
  58. .B \-C
  59. flag.  To ease the the impact of this change, when
  60. .I flex
  61. encounters
  62. .B \-c,
  63. it currently issues a warning message and assumes that
  64. .B \-C
  65. was desired instead.  In the future this "promotion" of
  66. .B \-c
  67. to
  68. .B \-C
  69. will go away in the name of full POSIX compliance (unless
  70. the POSIX meaning is removed first).
  71. .TP
  72. .B \-d
  73. makes the generated scanner run in
  74. .I debug
  75. mode.  Whenever a pattern is recognized and the global
  76. .B yy_flex_debug
  77. is non-zero (which is the default), the scanner will
  78. write to
  79. .I stderr
  80. a line of the form:
  81. .nf
  82.  
  83.     --accepting rule at line 53 ("the matched text")
  84.  
  85. .fi
  86. The line number refers to the location of the rule in the file
  87. defining the scanner (i.e., the file that was fed to flex).  Messages
  88. are also generated when the scanner backs up, accepts the
  89. default rule, reaches the end of its input buffer (or encounters
  90. a NUL; the two look the same as far as the scanner's concerned),
  91. or reaches an end-of-file.
  92. .TP
  93. .B \-f
  94. specifies
  95. .I fast scanner.
  96. No table compression is done and stdio is bypassed.
  97. The result is large but fast.  This option is equivalent to
  98. .B \-Cfr
  99. (see below).
  100. .TP
  101. .B \-h
  102. generates a "help" summary of
  103. .I flex's
  104. options to
  105. .I stderr 
  106. and then exits.
  107. .TP
  108. .B \-i
  109. instructs
  110. .I flex
  111. to generate a
  112. .I case-insensitive
  113. scanner.  The case of letters given in the
  114. .I flex
  115. input patterns will
  116. be ignored, and tokens in the input will be matched regardless of case.  The
  117. matched text given in
  118. .I yytext
  119. will have the preserved case (i.e., it will not be folded).
  120. .TP
  121. .B \-l
  122. turns on maximum compatibility with the original AT&T lex implementation,
  123. at a considerable performance cost.  This option is incompatible with
  124. .B \-+, \-f, \-F, \-Cf,
  125. or
  126. .B \-CF.
  127. See
  128. .I flexdoc(1)
  129. for details.
  130. .TP
  131. .B \-n
  132. is another do-nothing, deprecated option included only for
  133. POSIX compliance.
  134. .TP
  135. .B \-p
  136. generates a performance report to stderr.  The report
  137. consists of comments regarding features of the
  138. .I flex
  139. input file which will cause a loss of performance in the resulting scanner.
  140. If you give the flag twice, you will also get comments regarding
  141. features that lead to minor performance losses.
  142. .TP
  143. .B \-s
  144. causes the
  145. .I default rule
  146. (that unmatched scanner input is echoed to
  147. .I stdout)
  148. to be suppressed.  If the scanner encounters input that does not
  149. match any of its rules, it aborts with an error.
  150. .TP
  151. .B \-t
  152. instructs
  153. .I flex
  154. to write the scanner it generates to standard output instead
  155. of
  156. .B lex.yy.c.
  157. .TP
  158. .B \-v
  159. specifies that
  160. .I flex
  161. should write to
  162. .I stderr
  163. a summary of statistics regarding the scanner it generates.
  164. .TP
  165. .B \-w
  166. suppresses warning messages.
  167. .TP
  168. .B \-B
  169. instructs
  170. .I flex
  171. to generate a
  172. .I batch
  173. scanner instead of an
  174. .I interactive
  175. scanner (see
  176. .B \-I
  177. below).  See
  178. .I flexdoc(1)
  179. for details.  Scanners using
  180. .B \-Cf
  181. or
  182. .B \-CF
  183. compression options automatically specify this option, too.
  184. .TP
  185. .B \-F
  186. specifies that the
  187. .ul
  188. fast
  189. scanner table representation should be used (and stdio bypassed).
  190. This representation is about as fast as the full table representation
  191. .B (-f),
  192. and for some sets of patterns will be considerably smaller (and for
  193. others, larger).  It cannot be used with the
  194. .B \-+
  195. option.  See
  196. .B flexdoc(1)
  197. for more details.
  198. .IP
  199. This option is equivalent to
  200. .B \-CFr
  201. (see below).
  202. .TP
  203. .B \-I
  204. instructs
  205. .I flex
  206. to generate an
  207. .I interactive
  208. scanner, that is, a scanner which stops immediately rather than
  209. looking ahead if it knows
  210. that the currently scanned text cannot be part of a longer rule's match.
  211. This is the opposite of
  212. .I batch
  213. scanners (see
  214. .B \-B
  215. above).  See
  216. .B flexdoc(1)
  217. for details.
  218. .IP
  219. Note,
  220. .B \-I
  221. cannot be used in conjunction with
  222. .I full
  223. or
  224. .I fast tables,
  225. i.e., the
  226. .B \-f, \-F, \-Cf,
  227. or
  228. .B \-CF
  229. flags.  For other table compression options,
  230. .B \-I
  231. is the default.
  232. .TP
  233. .B \-L
  234. instructs
  235. .I flex
  236. not to generate
  237. .B #line
  238. directives in
  239. .B lex.yy.c.
  240. The default is to generate such directives so error
  241. messages in the actions will be correctly
  242. located with respect to the original
  243. .I flex
  244. input file, and not to
  245. the fairly meaningless line numbers of
  246. .B lex.yy.c.
  247. .TP
  248. .B \-T
  249. makes
  250. .I flex
  251. run in
  252. .I trace
  253. mode.  It will generate a lot of messages to
  254. .I stderr
  255. concerning
  256. the form of the input and the resultant non-deterministic and deterministic
  257. finite automata.  This option is mostly for use in maintaining
  258. .I flex.
  259. .TP
  260. .B \-V
  261. prints the version number to
  262. .I stderr
  263. and exits.
  264. .TP
  265. .B \-7
  266. instructs
  267. .I flex
  268. to generate a 7-bit scanner, which can save considerable table space,
  269. especially when using
  270. .B \-Cf
  271. or
  272. .B \-CF
  273. (and, at most sites,
  274. .B \-7
  275. is on by default for these options.  To see if this is the case, use the
  276. .B -v
  277. verbose flag and check the flag summary it reports).
  278. .TP
  279. .B \-8
  280. instructs
  281. .I flex
  282. to generate an 8-bit scanner.  This is the default except for the
  283. .B \-Cf
  284. and
  285. .B \-CF
  286. compression options, for which the default is site-dependent, and
  287. can be checked by inspecting the flag summary generated by the
  288. .B \-v
  289. option.
  290. .TP
  291. .B \-+
  292. specifies that you want flex to generate a C++
  293. scanner class.  See the section on Generating C++ Scanners in
  294. .I flexdoc(1)
  295. for details.
  296. .TP 
  297. .B \-C[aefFmr]
  298. controls the degree of table compression and scanner optimization.
  299. .IP
  300. .B \-Ca
  301. trade off larger tables in the generated scanner for faster performance
  302. because the elements of the tables are better aligned for memory access
  303. and computation.  This option can double the size of the tables used by
  304. your scanner.
  305. .IP
  306. .B \-Ce
  307. directs
  308. .I flex
  309. to construct
  310. .I equivalence classes,
  311. i.e., sets of characters
  312. which have identical lexical properties.
  313. Equivalence classes usually give
  314. dramatic reductions in the final table/object file sizes (typically
  315. a factor of 2-5) and are pretty cheap performance-wise (one array
  316. look-up per character scanned).
  317. .IP
  318. .B \-Cf
  319. specifies that the
  320. .I full
  321. scanner tables should be generated -
  322. .I flex
  323. should not compress the
  324. tables by taking advantages of similar transition functions for
  325. different states.
  326. .IP
  327. .B \-CF
  328. specifies that the alternate fast scanner representation (described in
  329. .B flexdoc(1))
  330. should be used.  This option cannot be used with
  331. .B \-+.
  332. .IP
  333. .B \-Cm
  334. directs
  335. .I flex
  336. to construct
  337. .I meta-equivalence classes,
  338. which are sets of equivalence classes (or characters, if equivalence
  339. classes are not being used) that are commonly used together.  Meta-equivalence
  340. classes are often a big win when using compressed tables, but they
  341. have a moderate performance impact (one or two "if" tests and one
  342. array look-up per character scanned).
  343. .IP
  344. .B \-Cr
  345. causes the generated scanner to
  346. .I bypass
  347. using stdio for input.  In general this option results in a minor
  348. performance gain only worthwhile if used in conjunction with
  349. .B \-Cf
  350. or
  351. .B \-CF.
  352. It can cause surprising behavior if you use stdio yourself to
  353. read from
  354. .I yyin
  355. prior to calling the scanner.
  356. .IP
  357. A lone
  358. .B \-C
  359. specifies that the scanner tables should be compressed but neither
  360. equivalence classes nor meta-equivalence classes should be used.
  361. .IP
  362. The options
  363. .B \-Cf
  364. or
  365. .B \-CF
  366. and
  367. .B \-Cm
  368. do not make sense together - there is no opportunity for meta-equivalence
  369. classes if the table is not being compressed.  Otherwise the options
  370. may be freely mixed.
  371. .IP
  372. The default setting is
  373. .B \-Cem,
  374. which specifies that
  375. .I flex
  376. should generate equivalence classes
  377. and meta-equivalence classes.  This setting provides the highest
  378. degree of table compression.  You can trade off
  379. faster-executing scanners at the cost of larger tables with
  380. the following generally being true:
  381. .nf
  382.  
  383.     slowest & smallest
  384.           -Cem
  385.           -Cm
  386.           -Ce
  387.           -C
  388.           -C{f,F}e
  389.           -C{f,F}
  390.           -C{f,F}a
  391.     fastest & largest
  392.  
  393. .fi
  394. .IP
  395. .B \-C
  396. options are cumulative.
  397. .TP
  398. .B \-Pprefix
  399. changes the default
  400. .I "yy"
  401. prefix used by
  402. .I flex
  403. to be
  404. .I prefix
  405. instead.  See
  406. .I flexdoc(1)
  407. for a description of all the global variables and file names that
  408. this affects.
  409. .TP
  410. .B \-Sskeleton_file
  411. overrides the default skeleton file from which
  412. .I flex
  413. constructs its scanners.  You'll never need this option unless you are doing
  414. .I flex
  415. maintenance or development.
  416. .SH SUMMARY OF FLEX REGULAR EXPRESSIONS
  417. The patterns in the input are written using an extended set of regular
  418. expressions.  These are:
  419. .nf
  420.  
  421.     x          match the character 'x'
  422.     .          any character except newline
  423.     [xyz]      a "character class"; in this case, the pattern
  424.                  matches either an 'x', a 'y', or a 'z'
  425.     [abj-oZ]   a "character class" with a range in it; matches
  426.                  an 'a', a 'b', any letter from 'j' through 'o',
  427.                  or a 'Z'
  428.     [^A-Z]     a "negated character class", i.e., any character
  429.                  but those in the class.  In this case, any
  430.                  character EXCEPT an uppercase letter.
  431.     [^A-Z\\n]   any character EXCEPT an uppercase letter or
  432.                  a newline
  433.     r*         zero or more r's, where r is any regular expression
  434.     r+         one or more r's
  435.     r?         zero or one r's (that is, "an optional r")
  436.     r{2,5}     anywhere from two to five r's
  437.     r{2,}      two or more r's
  438.     r{4}       exactly 4 r's
  439.     {name}     the expansion of the "name" definition
  440.                (see above)
  441.     "[xyz]\\"foo"
  442.                the literal string: [xyz]"foo
  443.     \\X         if X is an 'a', 'b', 'f', 'n', 'r', 't', or 'v',
  444.                  then the ANSI-C interpretation of \\x.
  445.                  Otherwise, a literal 'X' (used to escape
  446.                  operators such as '*')
  447.     \\123       the character with octal value 123
  448.     \\x2a       the character with hexadecimal value 2a
  449.     (r)        match an r; parentheses are used to override
  450.                  precedence (see below)
  451.  
  452.  
  453.     rs         the regular expression r followed by the
  454.                  regular expression s; called "concatenation"
  455.  
  456.  
  457.     r|s        either an r or an s
  458.  
  459.  
  460.     r/s        an r but only if it is followed by an s.  The
  461.                  s is not part of the matched text.  This type
  462.                  of pattern is called as "trailing context".
  463.     ^r         an r, but only at the beginning of a line
  464.     r$         an r, but only at the end of a line.  Equivalent
  465.                  to "r/\\n".
  466.  
  467.  
  468.     <s>r       an r, but only in start condition s (see
  469.                below for discussion of start conditions)
  470.     <s1,s2,s3>r
  471.                same, but in any of start conditions s1,
  472.                s2, or s3
  473.     <*>r       an r in any start condition, even an exclusive one.
  474.  
  475.  
  476.     <<EOF>>    an end-of-file
  477.     <s1,s2><<EOF>>
  478.                an end-of-file when in start condition s1 or s2
  479.  
  480. .fi
  481. The regular expressions listed above are grouped according to
  482. precedence, from highest precedence at the top to lowest at the bottom.
  483. Those grouped together have equal precedence.
  484. .PP
  485. Some notes on patterns:
  486. .IP -
  487. Negated character classes
  488. .I match newlines
  489. unless "\\n" (or an equivalent escape sequence) is one of the
  490. characters explicitly present in the negated character class
  491. (e.g., "[^A-Z\\n]").
  492. .IP -
  493. A rule can have at most one instance of trailing context (the '/' operator
  494. or the '$' operator).  The start condition, '^', and "<<EOF>>" patterns
  495. can only occur at the beginning of a pattern, and, as well as with '/' and '$',
  496. cannot be grouped inside parentheses.  The following are all illegal:
  497. .nf
  498.  
  499.     foo/bar$
  500.     foo|(bar$)
  501.     foo|^bar
  502.     <sc1>foo<sc2>bar
  503.  
  504. .fi
  505. .SH SUMMARY OF SPECIAL ACTIONS
  506. In addition to arbitrary C code, the following can appear in actions:
  507. .IP -
  508. .B ECHO
  509. copies yytext to the scanner's output.
  510. .IP -
  511. .B BEGIN
  512. followed by the name of a start condition places the scanner in the
  513. corresponding start condition.
  514. .IP -
  515. .B REJECT
  516. directs the scanner to proceed on to the "second best" rule which matched the
  517. input (or a prefix of the input).
  518. .B yytext
  519. and
  520. .B yyleng
  521. are set up appropriately.  Note that
  522. .B REJECT
  523. is a particularly expensive feature in terms scanner performance;
  524. if it is used in
  525. .I any
  526. of the scanner's actions it will slow down
  527. .I all
  528. of the scanner's matching.  Furthermore,
  529. .B REJECT
  530. cannot be used with the
  531. .B \-f
  532. or
  533. .B \-F
  534. options.
  535. .IP
  536. Note also that unlike the other special actions,
  537. .B REJECT
  538. is a
  539. .I branch;
  540. code immediately following it in the action will
  541. .I not
  542. be executed.
  543. .IP -
  544. .B yymore()
  545. tells the scanner that the next time it matches a rule, the corresponding
  546. token should be
  547. .I appended
  548. onto the current value of
  549. .B yytext
  550. rather than replacing it.
  551. .IP -
  552. .B yyless(n)
  553. returns all but the first
  554. .I n
  555. characters of the current token back to the input stream, where they
  556. will be rescanned when the scanner looks for the next match.
  557. .B yytext
  558. and
  559. .B yyleng
  560. are adjusted appropriately (e.g.,
  561. .B yyleng
  562. will now be equal to
  563. .I n
  564. ).
  565. .IP -
  566. .B unput(c)
  567. puts the character
  568. .I c
  569. back onto the input stream.  It will be the next character scanned.
  570. .IP -
  571. .B input()
  572. reads the next character from the input stream (this routine is called
  573. .B yyinput()
  574. if the scanner is compiled using
  575. .B C++).
  576. .IP -
  577. .B yyterminate()
  578. can be used in lieu of a return statement in an action.  It terminates
  579. the scanner and returns a 0 to the scanner's caller, indicating "all done".
  580. .IP
  581. By default,
  582. .B yyterminate()
  583. is also called when an end-of-file is encountered.  It is a macro and
  584. may be redefined.
  585. .IP -
  586. .B YY_NEW_FILE
  587. is an action available only in <<EOF>> rules.  It means "Okay, I've
  588. set up a new input file, continue scanning".  It is no longer required;
  589. you can just assign
  590. .I yyin
  591. to point to a new file in the <<EOF>> action.
  592. .IP -
  593. .B yy_create_buffer( file, size )
  594. takes a
  595. .I FILE
  596. pointer and an integer
  597. .I size.
  598. It returns a YY_BUFFER_STATE
  599. handle to a new input buffer large enough to accomodate
  600. .I size
  601. characters and associated with the given file.  When in doubt, use
  602. .B YY_BUF_SIZE
  603. for the size.
  604. .IP -
  605. .B yy_switch_to_buffer( new_buffer )
  606. switches the scanner's processing to scan for tokens from
  607. the given buffer, which must be a YY_BUFFER_STATE.
  608. .IP -
  609. .B yy_delete_buffer( buffer )
  610. deletes the given buffer.
  611. .SH VALUES AVAILABLE TO THE USER
  612. .IP -
  613. .B char *yytext
  614. holds the text of the current token.  It may be modified but not lengthened
  615. (you cannot append characters to the end).  Modifying the last character
  616. may affect the activity of rules anchored using '^' during the next scan;
  617. see
  618. .B flexdoc(1)
  619. for details.
  620. .IP
  621. If the special directive
  622. .B %array
  623. appears in the first section of the scanner description, then
  624. .B yytext
  625. is instead declared
  626. .B char yytext[YYLMAX],
  627. where
  628. .B YYLMAX
  629. is a macro definition that you can redefine in the first section
  630. if you don't like the default value (generally 8KB).  Using
  631. .B %array
  632. results in somewhat slower scanners, but the value of
  633. .B yytext
  634. becomes immune to calls to
  635. .I input()
  636. and
  637. .I unput(),
  638. which potentially destroy its value when
  639. .B yytext
  640. is a character pointer.  The opposite of
  641. .B %array
  642. is
  643. .B %pointer,
  644. which is the default.
  645. .IP
  646. You cannot use
  647. .B %array
  648. when generating C++ scanner classes
  649. (the
  650. .B \-+
  651. flag).
  652. .IP -
  653. .B int yyleng
  654. holds the length of the current token.
  655. .IP -
  656. .B FILE *yyin
  657. is the file which by default
  658. .I flex
  659. reads from.  It may be redefined but doing so only makes sense before
  660. scanning begins or after an EOF has been encountered.  Changing it in
  661. the midst of scanning will have unexpected results since
  662. .I flex
  663. buffers its input; use
  664. .B yyrestart()
  665. instead.
  666. Once scanning terminates because an end-of-file
  667. has been seen,
  668. .B
  669. you can assign
  670. .I yyin
  671. at the new input file and then call the scanner again to continue scanning.
  672. .IP -
  673. .B void yyrestart( FILE *new_file )
  674. may be called to point
  675. .I yyin
  676. at the new input file.  The switch-over to the new file is immediate
  677. (any previously buffered-up input is lost).  Note that calling
  678. .B yyrestart()
  679. with
  680. .I yyin
  681. as an argument thus throws away the current input buffer and continues
  682. scanning the same input file.
  683. .IP -
  684. .B FILE *yyout
  685. is the file to which
  686. .B ECHO
  687. actions are done.  It can be reassigned by the user.
  688. .IP -
  689. .B YY_CURRENT_BUFFER
  690. returns a
  691. .B YY_BUFFER_STATE
  692. handle to the current buffer.
  693. .IP -
  694. .B YY_START
  695. returns an integer value corresponding to the current start
  696. condition.  You can subsequently use this value with
  697. .B BEGIN
  698. to return to that start condition.
  699. .SH MACROS AND FUNCTIONS YOU CAN REDEFINE
  700. .IP -
  701. .B YY_DECL
  702. controls how the scanning routine is declared.
  703. By default, it is "int yylex()", or, if prototypes are being
  704. used, "int yylex(void)".  This definition may be changed by redefining
  705. the "YY_DECL" macro.  Note that
  706. if you give arguments to the scanning routine using a
  707. K&R-style/non-prototyped function declaration, you must terminate
  708. the definition with a semi-colon (;).
  709. .IP -
  710. The nature of how the scanner
  711. gets its input can be controlled by redefining the
  712. .B YY_INPUT
  713. macro.
  714. YY_INPUT's calling sequence is "YY_INPUT(buf,result,max_size)".  Its
  715. action is to place up to
  716. .I max_size
  717. characters in the character array
  718. .I buf
  719. and return in the integer variable
  720. .I result
  721. either the
  722. number of characters read or the constant YY_NULL (0 on Unix systems)
  723. to indicate EOF.  The default YY_INPUT reads from the
  724. global file-pointer "yyin".
  725. A sample redefinition of YY_INPUT (in the definitions
  726. section of the input file):
  727. .nf
  728.  
  729.     %{
  730.     #undef YY_INPUT
  731.     #define YY_INPUT(buf,result,max_size) \\
  732.         { \\
  733.         int c = getchar(); \\
  734.         result = (c == EOF) ? YY_NULL : (buf[0] = c, 1); \\
  735.         }
  736.     %}
  737.  
  738. .fi
  739. .IP -
  740. When the scanner receives an end-of-file indication from YY_INPUT,
  741. it then checks the function
  742. .B yywrap()
  743. function.  If
  744. .B yywrap()
  745. returns false (zero), then it is assumed that the
  746. function has gone ahead and set up
  747. .I yyin
  748. to point to another input file, and scanning continues.  If it returns
  749. true (non-zero), then the scanner terminates, returning 0 to its
  750. caller.
  751. .IP
  752. The default
  753. .B yywrap()
  754. always returns 1.
  755. .IP -
  756. YY_USER_ACTION
  757. can be redefined to provide an action
  758. which is always executed prior to the matched rule's action.
  759. .IP -
  760. The macro
  761. .B YY_USER_INIT
  762. may be redefined to provide an action which is always executed before
  763. the first scan.
  764. .IP -
  765. In the generated scanner, the actions are all gathered in one large
  766. switch statement and separated using
  767. .B YY_BREAK,
  768. which may be redefined.  By default, it is simply a "break", to separate
  769. each rule's action from the following rule's.
  770. .SH FILES
  771. .TP
  772. .B \-lfl
  773. library with which to link scanners to obtain the default versions
  774. of
  775. .I yywrap()
  776. and/or
  777. .I main().
  778. .TP
  779. .I lex.yy.c
  780. generated scanner (called
  781. .I lexyy.c
  782. on some systems).
  783. .TP
  784. .I lex.yy.cc
  785. generated C++ scanner class, when using
  786. .B -+.
  787. .TP
  788. .I <FlexLexer.h>
  789. header file defining the C++ scanner base class,
  790. .B FlexLexer,
  791. and its derived class,
  792. .B yyFlexLexer.
  793. .TP
  794. .I flex.skl
  795. skeleton scanner.  This file is only used when building flex, not when
  796. flex executes.
  797. .TP
  798. .I lex.backup
  799. backing-up information for
  800. .B \-b
  801. flag (called
  802. .I lex.bck
  803. on some systems).
  804. .SH "SEE ALSO"
  805. .PP
  806. flexdoc(1), lex(1), yacc(1), sed(1), awk(1).
  807. .PP
  808. M. E. Lesk and E. Schmidt,
  809. .I LEX \- Lexical Analyzer Generator
  810. .SH DIAGNOSTICS
  811. .PP
  812. .I reject_used_but_not_detected undefined
  813. or
  814. .PP
  815. .I yymore_used_but_not_detected undefined -
  816. These errors can occur at compile time.  They indicate that the
  817. scanner uses
  818. .B REJECT
  819. or
  820. .B yymore()
  821. but that
  822. .I flex
  823. failed to notice the fact, meaning that
  824. .I flex
  825. scanned the first two sections looking for occurrences of these actions
  826. and failed to find any, but somehow you snuck some in (via a #include
  827. file, for example).  Make an explicit reference to the action in your
  828. .I flex
  829. input file.  (Note that previously
  830. .I flex
  831. supported a
  832. .B %used/%unused
  833. mechanism for dealing with this problem; this feature is still supported
  834. but now deprecated, and will go away soon unless the author hears from
  835. people who can argue compellingly that they need it.)
  836. .PP
  837. .I flex scanner jammed -
  838. a scanner compiled with
  839. .B \-s
  840. has encountered an input string which wasn't matched by
  841. any of its rules.
  842. .PP
  843. .I warning, rule cannot be matched
  844. indicates that the given rule
  845. cannot be matched because it follows other rules that will
  846. always match the same text as it.  See
  847. .I flexdoc(1)
  848. for an example.
  849. .PP
  850. .I warning,
  851. .B \-s
  852. .I
  853. option given but default rule can be matched
  854. means that it is possible (perhaps only in a particular start condition)
  855. that the default rule (match any single character) is the only one
  856. that will match a particular input.  Since
  857. .PP
  858. .I scanner input buffer overflowed -
  859. a scanner rule matched more text than the available dynamic memory.
  860. .PP
  861. .I token too large, exceeds YYLMAX -
  862. your scanner uses
  863. .B %array
  864. and one of its rules matched a string longer than the
  865. .B YYLMAX
  866. constant (8K bytes by default).  You can increase the value by
  867. #define'ing
  868. .B YYLMAX
  869. in the definitions section of your
  870. .I flex
  871. input.
  872. .PP
  873. .I scanner requires \-8 flag to
  874. .I use the character 'x' -
  875. Your scanner specification includes recognizing the 8-bit character
  876. .I 'x'
  877. and you did not specify the \-8 flag, and your scanner defaulted to 7-bit
  878. because you used the
  879. .B \-Cf
  880. or
  881. .B \-CF
  882. table compression options.
  883. .PP
  884. .I flex scanner push-back overflow -
  885. you used
  886. .B unput()
  887. to push back so much text that the scanner's buffer could not hold
  888. both the pushed-back text and the current token in
  889. .B yytext.
  890. Ideally the scanner should dynamically resize the buffer in this case, but at
  891. present it does not.
  892. .PP
  893. .I
  894. input buffer overflow, can't enlarge buffer because scanner uses REJECT -
  895. the scanner was working on matching an extremely large token and needed
  896. to expand the input buffer.  This doesn't work with scanners that use
  897. .B
  898. REJECT.
  899. .PP
  900. .I
  901. fatal flex scanner internal error--end of buffer missed -
  902. This can occur in an scanner which is reentered after a long-jump
  903. has jumped out (or over) the scanner's activation frame.  Before
  904. reentering the scanner, use:
  905. .nf
  906.  
  907.     yyrestart( yyin );
  908.  
  909. .fi
  910. or use C++ scanner classes (the
  911. .B \-+
  912. option), which are fully reentrant.
  913. .SH AUTHOR
  914. Vern Paxson, with the help of many ideas and much inspiration from
  915. Van Jacobson.  Original version by Jef Poskanzer.
  916. .PP
  917. See flexdoc(1) for additional credits and the address to send comments to.
  918. .SH DEFICIENCIES / BUGS
  919. .PP
  920. Some trailing context
  921. patterns cannot be properly matched and generate
  922. warning messages ("dangerous trailing context").  These are
  923. patterns where the ending of the
  924. first part of the rule matches the beginning of the second
  925. part, such as "zx*/xy*", where the 'x*' matches the 'x' at
  926. the beginning of the trailing context.  (Note that the POSIX draft
  927. states that the text matched by such patterns is undefined.)
  928. .PP
  929. For some trailing context rules, parts which are actually fixed-length are
  930. not recognized as such, leading to the abovementioned performance loss.
  931. In particular, parts using '|' or {n} (such as "foo{3}") are always
  932. considered variable-length.
  933. .PP
  934. Combining trailing context with the special '|' action can result in
  935. .I fixed
  936. trailing context being turned into the more expensive
  937. .I variable
  938. trailing context.  For example, in the following:
  939. .nf
  940.  
  941.     %%
  942.     abc      |
  943.     xyz/def
  944.  
  945. .fi
  946. .PP
  947. Use of
  948. .B unput()
  949. or
  950. .B input()
  951. invalidates yytext and yyleng, unless the
  952. .B %array
  953. directive
  954. or the
  955. .B \-l
  956. option has been used.
  957. .PP
  958. Use of unput() to push back more text than was matched can
  959. result in the pushed-back text matching a beginning-of-line ('^')
  960. rule even though it didn't come at the beginning of the line
  961. (though this is rare!).
  962. .PP
  963. Pattern-matching of NUL's is substantially slower than matching other
  964. characters.
  965. .PP
  966. Dynamic resizing of the input buffer is slow, as it entails rescanning
  967. all the text matched so far by the current (generally huge) token.
  968. .PP
  969. .I flex
  970. does not generate correct #line directives for code internal
  971. to the scanner; thus, bugs in
  972. .I flex.skl
  973. yield bogus line numbers.
  974. .PP
  975. Due to both buffering of input and read-ahead, you cannot intermix
  976. calls to <stdio.h> routines, such as, for example,
  977. .B getchar(),
  978. with
  979. .I flex
  980. rules and expect it to work.  Call
  981. .B input()
  982. instead.
  983. .PP
  984. The total table entries listed by the
  985. .B \-v
  986. flag excludes the number of table entries needed to determine
  987. what rule has been matched.  The number of entries is equal
  988. to the number of DFA states if the scanner does not use
  989. .B REJECT,
  990. and somewhat greater than the number of states if it does.
  991. .PP
  992. .B REJECT
  993. cannot be used with the
  994. .B \-f
  995. or
  996. .B \-F
  997. options.
  998. .PP
  999. The
  1000. .I flex
  1001. internal algorithms need documentation.
  1002.